﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Data;
using CPPEI.Coolzon.Service.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Server.ServiceImplement
{
    public class ReqTabChangeHandler : BaseHandler<ReqTabChangeData, RespTabChangeData>
    {
        public ReqTabChangeHandler()
            : base(RESPONSE_SCENARIO.TABCONTAINER, RESPONSE_COMMAND.TABCONTAINER.CHANGE)
        {
        }

        protected override RespTabChangeData OnHandle(Data.MainServiceData.Request request, ReqTabChangeData requestData)
        {
            CacheData.ControlDomain domain = CacheData.ServerData.Instance.GetDomain(request.Header.DomainId);
            if (domain != null)
            {
                domain.UpdateViewState(domain.SolutionName, requestData.ViewStateAge, requestData.ViewStateToken);
            }

            RespTabChangeData respTabChangeData = new RespTabChangeData();
            respTabChangeData.NewTabIndex = requestData.NewTabIndex;
            respTabChangeData.OldTabIndex = requestData.OldTabIndex;
            respTabChangeData.Scene = requestData.Scene;
            respTabChangeData.TabContainer = requestData.TabContainer;
            return respTabChangeData;
        }
    }
}
